<template>
  <div class="header-info">
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">区域设置</el-divider>
      </div>
      <el-form-item label="区域高度">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo.areaHeight"
        />
      </el-form-item>
    </div>

    <!--科室设置-->
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">科室&诊室</el-divider>
      </div>
      <!--诊室&科室-->
      <el-form-item
          label="科室号别设定"
          class="dept-number-room-set"
      >
        <template v-if="optionsInfo?.deptRoomOptions?.length">
          <el-checkbox-group
              :min="1"
              v-model="optionsInfo.defaultShowCol"
              @change="(e) => handleChangeDept(e)"
          >
            <el-checkbox
                v-for="item in (optionsInfo.deptRoomOptions)"
                :label="item.value"
                :key="item.value"

            >
              {{ item.label }}
            </el-checkbox>
          </el-checkbox-group>
        </template>
      </el-form-item>

      <el-form-item label="科室字号" v-if="!!(optionsInfo.deptNameFontSize)">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.deptNameFontSize"
            :disabled="!(optionsInfo.defaultShowCol).includes('deptName')"
        />
      </el-form-item>

      <el-form-item label="诊室字号" v-if="!!(optionsInfo.roomNameFontSize)">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.roomNameFontSize"
            :disabled="!(optionsInfo.defaultShowCol).includes('roomName')"
        />
      </el-form-item>

      <el-form-item label="背景颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['deptRoomInfoBackground']"
        />
      </el-form-item>

      <el-form-item label="字体颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['deptRoomInfoFontColor']"
        />
      </el-form-item>

      <!--诊室选中字段-->
      <template v-if="false&&optionsInfo['defaultShowCol'].includes('roomName')">
        <roomNameKeyEditor
            :designer="designer"
            :selected-widget="selectedWidget"
            :option-model="optionModel"
        />
      </template>
    </div>

    <!--医生信息设置-->
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">医生信息设置</el-divider>
      </div>
      <!--诊室&科室-->
      <el-form-item
          label="医生信息"
          class="dept-number-room-set"
      >
        <template v-if="optionsInfo?.doctorInfoOptions?.length">
          <el-checkbox-group
              :min="1"
              v-model="optionsInfo.doctorInfoDefaultShowCol"
          >
            <el-checkbox
                v-for="item in (optionsInfo.doctorInfoOptions)"
                :label="item.value"
                :key="item.value"
                :disabled="item.disabled"
            >
              {{ item.label }}
            </el-checkbox>
          </el-checkbox-group>
        </template>
      </el-form-item>

      <el-form-item label="医生姓名字号" v-if="fieldHas('workerNameFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.workerNameFontSize"
            :disabled="!(optionsInfo.doctorInfoDefaultShowCol).includes('workerName')"
        />
      </el-form-item>

      <el-form-item label="医院职称字号" v-if="fieldHas('workerTitleFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.workerTitleFontSize"
            :disabled="!(optionsInfo.doctorInfoDefaultShowCol).includes('workerTitle')"
        />
      </el-form-item>

      <el-form-item label="学术职称字号" v-if="fieldHas('workerDegreeFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.workerDegreeFontSize"
            :disabled="!(optionsInfo.doctorInfoDefaultShowCol).includes('workerDegree')"
        />
      </el-form-item>

      <el-form-item label="医生科室字号" v-if="fieldHas('doctorDeptNameFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.doctorDeptNameFontSize"
            :disabled="!(optionsInfo.doctorInfoDefaultShowCol).includes('deptName')"
        />
      </el-form-item>

    </div>

    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">医生介绍</el-divider>
      </div>

      <el-form-item label="标题字号" v-if="fieldHas('doctorIntroduceSignFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.doctorIntroduceSignFontSize"
        />
      </el-form-item>

      <el-form-item label="内容字号" v-if="fieldHas('doctorIntroduceContentFontSize')">
        <el-input-number
            :min="12"
            size="small"
            v-model="optionsInfo.doctorIntroduceContentFontSize"
        />
      </el-form-item>

      <el-form-item label="标题字体颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['doctorIntroduceSignBackground']"
        />
      </el-form-item>
    </div>
  </div>
</template>

<script>
import Draggable from "vuedraggable";
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import * as types from "@c/public/form-designer/devType/datas-types";
import roomNameKeyEditor
  from "@sc/templateDetails/modules/homeRight/property-editor/module/scene-edit/basicInfo/roomNameKey-editor.vue";

export default {
  name: "publishRoomDoctor-editor",

  componentName: "publishRoomDoctor-editor",

  mixins: [],

  components: {roomNameKeyEditor, Draggable},

  props: {
    designer: Object,
    optionModel: Object,
    selectedWidget: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      radio: 1,
      screenType: '',
      optionsInfo: Object(),
      constantDic: constantDic,
      ApiTypeOptions: [
        {
          value: 1,
          label: '接口地址'
        },
        {
          value: 2,
          label: '接口标识'
        }
      ],
      predefineColors: types['predefineColors'],
      fontWeightOptions: types['fontWeightOptions'],
    }
  },

  computed: {
    // 判断字段是否存在
    fieldHas() {
      return function (field) {
        return Reflect.has(this.optionsInfo, field)
      }
    },
  },

  methods: {
    // 改变可是和诊室
    handleChangeDept(event) {
      let val = this.$lodash.uniqBy(event);
      if (val?.length === 1) {
        Reflect.set((this.optionsInfo), 'deptNameFontSize', 150);
        Reflect.set((this.optionsInfo), 'roomNameFontSize', 150)
      } else {
        Reflect.set((this.optionsInfo), 'deptNameFontSize', 92);
        Reflect.set((this.optionsInfo), 'roomNameFontSize', 120)
      }
      Reflect.set(this.optionsInfo, 'defaultShowCol', val)
    },
  },

  watch: {
    optionModel: {
      handler: function (val) {
        let key = (val.config)
        this.optionsInfo = val[key];
      },
      deep: true,
      immediate: true
    }
  }
}
</script>


<style lang="scss" scoped>
//科室 诊室 号别
.dept-number-room-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
    margin-bottom: 8px;
    @include fontWeight();
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;

    .el-checkbox-group {
      display: flex;
      flex-direction: column;
    }
  }
}
</style>